package xyz.chaobei.swagger.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import xyz.chaobei.swagger.model.OrgUser;

import java.util.LinkedList;
import java.util.List;


@Api(tags = "用户管理")
@RestController
@RequestMapping("/orgUser/")
public class OrgUserController {

    private static final List<OrgUser> free = new LinkedList<>();


    @GetMapping("/{id}")
    @ApiOperation("获取单个用户")
    public OrgUser getOne(@PathVariable("id") @ApiParam("用户ID") Integer id) {
        return free.stream().filter(item -> item.getId().equals(id)).findFirst().get();
    }

    @PostMapping("/")
    @ApiOperation("保存一个用户")
    public Boolean save(@RequestBody @ApiParam("用户信息") OrgUser orgUser) {
        return free.add(orgUser);
    }


}
